<template>
<view class="container">
  <block v-for="(item, index) in type_list" :key="index">
    <view class="item" @tap="goUrl" :data-url="item.url">{{ item.name }}</view>
  </block>
</view>
</template>

"<script>
import common from '../../utils/common.js'
var app = getApp();

export default {
  data() {
    return {
      mer_id: 0,
      type_list: []
    };
  },

  onShareAppMessage: function () {},
  onReachBottom: function () {},
  onPullDownRefresh: function () {},
  onUnload: function () {},
  onHide: function () {},
  onShow: function () {},
  onReady: function () {},
  onLoad: function (options) {
    if (!options.mer_id) {
      options.mer_id = app.merchantOwn.mer_id;
    }

    this.setData({
      mer_id: options.mer_id
    });

    if (!app.globalData.userInfo) {
      var that = this; //调用应用实例的方法获取全局数据

      common.getUserInfo(function (userInfo) {
        that.setMainContent();
      }, 'setting');
    } else {
      if (!app.globalData.userInfo.phone) {
        wx.navigateTo({
          url: "../my/newnumber"
        });
      } else {
        this.setMainContent();
      }
    }
  },
  components: {},
  props: {},
  methods: {
    setMainContent: function () {
      common.post('Wxapp_merchant&a=order_type_list', {
        mer_id: this.mer_id
      }, "setOrderTypeContent", this);
    },
    setOrderTypeContent: function (result) {
      this.setData({
        type_list: result
      });
      wx.hideToast();
    },
    goUrl: function (e) {
      common.parseUrl(e.currentTarget.dataset.url, 'all');
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
page{
  background:white;
}
.item{
  height:120rpx;
  line-height:120rpx;
  padding-left:30rpx;
  border-bottom:1rpx solid #f1f1f1;
  position:relative;
}
/*.item:last-child{
  border-bottom:none;
}*/

.item:after{
    display: block;
    content: "";
    border-top:2rpx solid #BFBFBF;
    border-left:2rpx solid #BFBFBF;
    width:16rpx;
    height:16rpx;
    -webkit-transform: rotate(135deg);
    background-color: transparent;
    position: absolute;
    top: 50%;
    right:46rpx;
    margin-top: -10rpx;
}
</style>